#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int min(int a, int b)
{
    if (a < b)
        return a;
    else
        return b;
}
int main()
{
    int n, m, i, j;
    while (scanf("%d%d", &m, &n) != EOF)
    {
        int heng[200][200] = { 0 };
        int shu[200][200] = { 0 };
        int h[101][101] = { 0 };
        for (i = 1; i <= m; i++)
        {
            for (j = 1; j <= n - 1; j++)
            {
                scanf("%d", &heng[i][j]);
            }
        }
        for (i = 1; i <= n; i++)
        {
            for (j = 1; j <= m - 1; j++)
            {
                scanf("%d", &shu[i][j]);
            }
        }
        h[1][1] = 0;
        for (i = 2; i <= n; i++)
        {
            h[1][i] = heng[1][i - 1] + h[1][i - 1];
        }
        for (j = 2; j <= m; j++)
        {
            h[j][1] = shu[1][j - 1] + h[j - 1][1];
        }
        for (i = 2; i <= m; i++)
        {
            for (j = 2; j <= n; j++)
            {
                h[i][j] += min(h[i - 1][j] + shu[j][i - 1], h[i][j - 1] + heng[i][j - 1]);
            }
        }
        printf("%d\n", h[m][n]);
    }
    return 0;
}
